package cn.jietuo.kafkaspringboot;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhangx & jietuo_zx@163.com
 * @version 1.0
 * @date 2021/4/11
 * @description: 生产者
 */
@RestController
public class KafkaProducerController {

    private final static String TOPIC_NAME = "test";

    @Autowired
    private KafkaTemplate<String,String> kafkaTemplate;

    @RequestMapping("/send")
    public void sendMsg(){
        kafkaTemplate.send(TOPIC_NAME,0,"key","我要发送个啥来着");
    }

}
